{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chaining a PCA and a logistic regression"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The PCA does an unsupervised dimensionality reduction, while the logistic regression does the prediction.\n",
    "\n",
    "We use a GridSearchCV to set the dimensionality of the PCA"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQQAAADICAYAAAAOVZ9xAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJztnXd4XNW1t98ladS7VWx1XLCxKQbcYiB2gEsgCcVcMM0EEsAmCcSQm4SWj3ppueGGkBAImGIgGAiB2Bjia2MMgbiAGzbuVZYl2you6tKMtL4/ztEgGVnSSBqdmdF+n2eeOWWfc357ZrS09t5rry2qisFgMACEOS3AYDAEDsYgGAwGL8YgGAwGL8YgGAwGL8YgGAwGL8YgGAwGL8YgGAwGL8YgGAwGL8YgGAwGLxFOC+gpaWlpWlBQ4LQMgyGgWbVqVbmqpndWLugNQkFBAStXrnRahsEQ0IhIYVfKmSaDIeh48bNdvPjZLqdlhCTGIBiCjqU7ylm6o9xpGSFJ0DcZDP2PWdeNdVpCyNIvPITaRg9mmrfB0Dkh7yFMf2UlH20uZcFtZzE0I6HDspWVlZSWluJ2u/tInaE7VNVb309CtMthJYGDy+UiIyODxMTEHt0n5A1CZEQYnmZl+c6DHRqEyspKDhw4QHZ2NjExMYhIH6o0+EJhRQ0A+QPiHFYSGKgqdXV1FBcXA/TIKIR8k2H84AEALN9Z0WG50tJSsrOziY2NNcYgwMkfEGeMQStEhNjYWLKzsyktLe3RvULeIHxrcCoAK3Yd7LAfwe12ExMT01eyDIZeJyYmp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069dml+s7qIlVVrW3w6NRnl+q8tdYXfKSuUac+u1T/ub5EVVUrqht06rNLddGG/aqqeqCyTqc+u1SXbD6gqqrFh2q7pLuF/Px8ffXVV737v/rVr3TGjBkdXjN9+nS97bbbvnF8z549GhYWppWVld5jd955p1533XWqahmEc88913tu3rx5GhcXpx6PR1VVKysrFdBDhw6pqrb5o1BV3bBhg7pcLvV4PPrggw/q5Zdf7j3X1NSkWVlZumTJkk7rdfPNN+tvfvObNtqPP/54/fjjjzu9tj2DcNZZZ+m9996rZWVlHX1sx/zcWur60EMPefeffvpp/e53v6uq2mFdt23bpunp6bpo0SJtbGxsc88RI0bohx9+6N0vKSnRiIgIdbvdXoNQVFTkPT927FidM2dOu/p6ahD6RZMB2gYoaZD2IwwcONC7HRsbS3V1dYfli4qKGDJkyDeOl5SUkJqaSkLC15Gb+fn53kg3gMzMTO92TEwMaWlphIeHe/eBNs/Pzc1tcy+32015eTklJSXk5+d7z4WFhZGbm9vmWceqV2FhIU888QTJycneV1FRESUlJd36TF544QW2bt3KiBEjGDt2LPPnz2+33LE+t86e2VFdhw4dypNPPsn9999PRkYGV155pbcehYWFTJkyxVvHE044gfDwcA4cONCtevaEkA9dbmF4ZgLJsS72Haln76E6clNjO73mzRnf8m67wsPa7MdEhrfZT4x2tdlPjYtss5+REN1mPyvZ/0FQubm57Nix4xvHs7KyOHjwIFVVVV6jsGfPHrKzs7v9rKKiIu/2nj17cLlcpKWlkZWVxfr1673nVJWioqIuPSs3N5d77rmHe+65p83x/Ufq2X+k4/6T9sbkhw0bxpw5c2hubuadd97hsssuo6Kigri4tiMWx/rcOqOzul599dVcffXVVFZWMmPGDO644w5effVVcnNzefHFFznjjDO+cc/du3f7rKMn9BsPISxMODknGYCN+yodVtM33HDDDbz00kssXryY5uZmiouL2bx5M7m5uUycOJG77rqL+vp61q1bxwsvvMC0adO6/azXXnuNjRs3Ultby7333stll11GeHg4U6dO5f3332fx4sW43W6eeOIJoqKimDhxYqf3vOmmm3j22WdZs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xAMBoMXYxAMBoMXYxAMBoMXYxAMBoMXYxAMBoOX/w+zPLejCJyRbgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 288x216 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "% matplotlib inline\n",
    "\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn import linear_model, decomposition, datasets\n",
    "from sklearn.pipeline import Pipeline\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "\n",
    "logistic = linear_model.LogisticRegression()\n",
    "\n",
    "pca = decomposition.PCA()\n",
    "pipe = Pipeline(steps=[('pca', pca), ('logistic', logistic)])\n",
    "\n",
    "digits = datasets.load_digits()\n",
    "X_digits = digits.data\n",
    "y_digits = digits.target\n",
    "\n",
    "# Plot the PCA spectrum\n",
    "pca.fit(X_digits)\n",
    "\n",
    "plt.figure(1, figsize=(4, 3))\n",
    "plt.clf()\n",
    "plt.axes([.2, .2, .7, .7])\n",
    "plt.plot(pca.explained_variance_, linewidth=2)\n",
    "plt.axis('tight')\n",
    "plt.xlabel('n_components')\n",
    "plt.ylabel('explained_variance_')\n",
    "\n",
    "# Prediction\n",
    "n_components = [20, 40, 64]\n",
    "Cs = np.logspace(-4, 4, 3)\n",
    "\n",
    "# Parameters of pipelines can be set using ‘__’ separated parameter names:\n",
    "estimator = GridSearchCV(pipe,\n",
    "                         dict(pca__n_components=n_components,\n",
    "                              logistic__C=Cs))\n",
    "estimator.fit(X_digits, y_digits)\n",
    "\n",
    "plt.axvline(estimator.best_estimator_.named_steps['pca'].n_components,\n",
    "            linestyle=':', label='n_components chosen')\n",
    "plt.legend(prop=dict(size=12))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1797, 64)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAECCAYAAADesWqHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAC8tJREFUeJzt3X+o1fUdx/HXazetlpK2WoRGZgwhguUPZFHEphm2wv2zRKFgsaF/bJFsULZ/Rv/1V7Q/RiBWCzKjawkjtpaSEUGr3Wu2TG2UGCnVLTTM/lCy9/44X4eJ637v3f187jnn/XzAwXO9x/P63Ht9ne/3e+73nLcjQgBy+c5kLwBAfRQfSIjiAwlRfCAhig8kRPGBhLqi+LaX237X9nu21xfOesz2iO3dJXNOy7vc9g7be2y/Y/uewnnn2X7D9ltN3gMl85rMAdtv2n6+dFaTd8D227Z32R4qnDXD9hbb+2zvtX1dwax5zdd06nLU9roiYRExqRdJA5LelzRX0lRJb0m6umDejZIWSNpd6eu7TNKC5vp0Sf8u/PVZ0rTm+hRJr0v6UeGv8beSnpL0fKXv6QFJF1fKekLSr5rrUyXNqJQ7IOljSVeUuP9u2OIvlvReROyPiBOSnpb0s1JhEfGKpMOl7v8seR9FxM7m+heS9kqaVTAvIuJY8+GU5lLsLC3bsyXdKmljqYzJYvtCdTYUj0pSRJyIiM8rxS+V9H5EfFDizruh+LMkfXjaxwdVsBiTyfYcSfPV2QqXzBmwvUvSiKRtEVEy72FJ90r6umDGmULSi7aHba8pmHOlpE8lPd4cymy0fUHBvNOtkrS51J13Q/FTsD1N0rOS1kXE0ZJZEXEyIq6VNFvSYtvXlMixfZukkYgYLnH/3+KGiFgg6RZJv7Z9Y6Gcc9Q5LHwkIuZL+lJS0eegJMn2VEkrJA2WyuiG4h+SdPlpH89u/q5v2J6iTuk3RcRztXKb3dIdkpYXirhe0gr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AASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 288x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Compare the performance\n",
    "from sklearn.datasets import load_digits\n",
    "from sklearn.linear_model.logistic import LogisticRegression\n",
    "from sklearn import decomposition\n",
    "from sklearn.metrics import confusion_matrix\n",
    "from sklearn.metrics import accuracy_score\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "\n",
    "# load digital data\n",
    "digits, dig_label = load_digits(return_X_y=True)\n",
    "print(digits.shape)\n",
    "\n",
    "# draw one digital\n",
    "plt.gray() \n",
    "plt.matshow(digits[0].reshape([8, 8])) \n",
    "plt.show() \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "accuracy train = 0.998608, accuracy_test = 0.897222\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# calculate train/test data number\n",
    "N = len(digits)\n",
    "N_train = int(N*0.8)\n",
    "N_test = N - N_train\n",
    "\n",
    "# split train/test data\n",
    "x_train = digits[:N_train, :]\n",
    "y_train = dig_label[:N_train]\n",
    "x_test  = digits[N_train:, :]\n",
    "y_test  = dig_label[N_train:]\n",
    "\n",
    "# do logistic regression\n",
    "lr=LogisticRegression()\n",
    "lr.fit(x_train,y_train)\n",
    "\n",
    "pred_train = lr.predict(x_train)\n",
    "pred_test  = lr.predict(x_test)\n",
    "\n",
    "# calculate train/test accuracy\n",
    "acc_train = accuracy_score(y_train, pred_train)\n",
    "acc_test = accuracy_score(y_test, pred_test)\n",
    "print(\"accuracy train = %f, accuracy_test = %f\" % (acc_train, acc_test))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "accuracy train = 0.987474, accuracy_test = 0.894444\n"
     ]
    }
   ],
   "source": [
    "# do PCA with 'n_components=40'\n",
    "pca = decomposition.PCA(n_components=40)\n",
    "pca.fit(x_train)\n",
    "\n",
    "x_train_pca = pca.transform(x_train)\n",
    "x_test_pca = pca.transform(x_test)\n",
    "\n",
    "# do logistic regression\n",
    "lr=LogisticRegression()\n",
    "lr.fit(x_train_pca,y_train)\n",
    "\n",
    "pred_train = lr.predict(x_train_pca)\n",
    "pred_test  = lr.predict(x_test_pca)\n",
    "\n",
    "# calculate train/test accuracy\n",
    "acc_train = accuracy_score(y_train, pred_train)\n",
    "acc_test = accuracy_score(y_test, pred_test)\n",
    "print(\"accuracy train = %f, accuracy_test = %f\" % (acc_train, acc_test))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "accuracy train = 0.148921, accuracy_test = 0.102778\n"
     ]
    }
   ],
   "source": [
    "# do kernel PCA\n",
    "#   Ref: http://scikit-learn.org/stable/auto_examples/decomposition/plot_kernel_pca.html\n",
    "\n",
    "from sklearn.decomposition import PCA, KernelPCA\n",
    "\n",
    "kpca = KernelPCA(n_components=45, kernel=\"rbf\", fit_inverse_transform=True, gamma=10)\n",
    "kpca.fit(x_train)\n",
    "\n",
    "x_train_pca = kpca.transform(x_train)\n",
    "x_test_pca = kpca.transform(x_test)\n",
    "\n",
    "# do logistic regression\n",
    "lr=LogisticRegression()\n",
    "lr.fit(x_train_pca,y_train)\n",
    "\n",
    "pred_train = lr.predict(x_train_pca)\n",
    "pred_test  = lr.predict(x_test_pca)\n",
    "\n",
    "# calculate train/test accuracy\n",
    "acc_train = accuracy_score(y_train, pred_train)\n",
    "acc_test = accuracy_score(y_test, pred_test)\n",
    "print(\"accuracy train = %f, accuracy_test = %f\" % (acc_train, acc_test))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## References\n",
    "* [Pipelining: chaining a PCA and a logistic regression](http://scikit-learn.org/stable/auto_examples/plot_digits_pipe.html)\n",
    "* [PCA进行无监督降维](https://ljalphabeta.gitbooks.io/python-/content/pca.html)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
